﻿@using Smartstore.Core.Search.Facets
@using Smartstore.Core.Catalog.Attributes

@model ProductAttributeModel

@{
    var gridViewData = new ViewDataDictionary(ViewData);
    gridViewData["Parent"] = Model;
}

<div asp-validation-summary="All"></div>
<input type="hidden" asp-for="Id" />

<tabstrip id="productattribute-edit" sm-nav-style="Material">
    <tab sm-title="@T("Admin.Common.General")" sm-selected="true">
        <div sm-if="Model.Id != 0" class="adminContent">
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="Id" />
                </div>
                <div class="adminData">
                    <input asp-for="Id" sm-plaintext="true" readonly />
                    <span asp-validation-for="Id"></span>
                </div>
            </div>
        </div>

        @(Html.LocalizedEditor<ProductAttributeModel, ProductAttributeLocalizedModel>("productattribute-localized",
	    @<text>
            <div class="adminContent">
		        <div class="adminRow">
			        <div class="adminTitle">
				        <smart-label asp-for="Locales[item].Name" />
			        </div>
			        <div class="adminData">
				        @*IMPORTANT: Do not delete, this hidden element contains the id to assign localized values to the corresponding language *@
                        <input asp-for="Locales[item].LanguageId" type="hidden" />
                        <input asp-for="Locales[item].Name" />
				        <span asp-validation-for="Locales[item].Name"></span>
			        </div>
		        </div>
		        <div class="adminRow">
			        <div class="adminTitle">
                        <smart-label asp-for="Locales[item].Alias" />
			        </div>
                    <div class="adminData">
                        <input asp-for="Locales[item].Alias" />
                        <span asp-validation-for="Locales[item].Alias"></span>
                    </div>
		        </div>
		        <div class="adminRow">
			        <div class="adminTitle">
                        <smart-label asp-for="Locales[item].Description" />
			        </div>
                    <div class="adminData wide">
                        <html-editor asp-for="Locales[item].Description"
                                     save-url="@(Url.PatchLocalizedEntity<ProductAttribute>(nameof(ProductAttribute.Description), Model.Id, Model.Locales[item].LanguageId))" />
                        <span asp-validation-for="Locales[item].Description"></span>
                    </div>
		        </div>
	        </div>
        </text>
        ,
	    @<text>
            <div class="adminContent">
		        <div class="adminRow">
			        <div class="adminTitle">
				        <smart-label asp-for="Name" />
			        </div>
			        <div class="adminData">
                        <input asp-for="Name" />
				        <span asp-validation-for="Name"></span>
			        </div>
		        </div>
		        <div class="adminRow">
			        <div class="adminTitle">
                        <smart-label asp-for="Alias" />
			        </div>
                    <div class="adminData">
                        <input asp-for="Alias" />
                        <span asp-validation-for="Alias"></span>
                    </div>
		        </div>
		        <div class="adminRow">
			        <div class="adminTitle">
                        <smart-label asp-for="Description" />
			        </div>
                    <div class="adminData wide">
                        <html-editor asp-for="Description" save-url="@(Url.PatchEntity<ProductAttribute>(nameof(ProductAttribute.Description), Model.Id))" />
                        <span asp-validation-for="Description"></span>
                    </div>
		        </div>
	        </div>
	    </text>))

        <div class="adminContent">
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="DisplayOrder" />
                </div>
                <div class="adminData">
                    <editor asp-for="DisplayOrder" />
                    <span asp-validation-for="DisplayOrder"></span>
                </div>
            </div>
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="AllowFiltering" />
                </div>
                <div class="adminData">
                    <input asp-for="AllowFiltering" data-toggler-for="#pnlAllowFiltering" />
                    <span asp-validation-for="AllowFiltering"></span>
                </div>
            </div>
            <div class="adminRow" id="pnlAllowFiltering">
                <div class="adminTitle">
                    <smart-label asp-for="FacetTemplateHint" />
                </div>
                <div class="adminData">
                    <select asp-for="FacetTemplateHint" asp-items="Model.FacetTemplateHint.ToSelectList().Where(x => x.Value.ToInt() != (int)FacetTemplateHint.NumericRange).ToList()"></select>
                    <span asp-validation-for="FacetTemplateHint"></span>
                </div>
            </div>
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="IndexOptionNames" />
                </div>
                <div class="adminData">
                    <input asp-for="IndexOptionNames" />
                    <span asp-validation-for="IndexOptionNames"></span>
                </div>
            </div>
            <div class="adminRow">
                <div class="adminTitle">
                    <smart-label asp-for="ExportMappings" />
                </div>
                <div class="adminData">
                    <editor asp-for="ExportMappings" />
                    <span asp-validation-for="ExportMappings"></span>
                </div>
            </div>
            <div class="adminRow">
                <div class="adminTitle">&nbsp;</div>
                <div class="adminData">
                    <div class="alert alert-info">
                        @Html.Raw(T("Admin.Catalog.Attributes.ProductAttributes.Fields.ExportMappings.Note"))
                    </div>
                </div>
            </div>
        </div>
    </tab>
    <tab sm-title="@T("Admin.Catalog.Attributes.OptionsSets")" sm-adaptive-height="true">
        @if (Model.Id > 0)
        {
            <partial name="_Grid.ProductAttributeOptionsSets" model="null" view-data="gridViewData" />
        }
        else
        {
            <div class="alert alert-warning">
                @T("Admin.SaveBeforeEdit")
            </div>
        }
    </tab>
</tabstrip>
